<?php
// Tim'Roster
// Copyright (c) 2011 Nicolas Nallet <aspgic2@gmail.com>
//
// This file is part of Tim'Roster.
//
// Tim'Roster is free software; you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// Tim'Roster is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA

$xml_config = simplexml_load_file('config.xml');

include_once($_SERVER["DOCUMENT_ROOT"].$xml_config->roster_root_directory.'/technical_class/authentification/User.php');
include_once ($_SERVER["DOCUMENT_ROOT"].$xml_config->roster_root_directory.'/web_ui/common_function.php');
require_once($_SERVER["DOCUMENT_ROOT"].$xml_config->roster_root_directory.'/external_libraries/ryzom_api/ryzom_api.php');
require_once($_SERVER["DOCUMENT_ROOT"].$xml_config->roster_root_directory.'/class/Guild.php');




function render_new_menu($guild){

    $content = '<fieldset class="menu"><br/>';


    if (isset($guild)) {
        $content .= '<ul><table><tr><td width="5"></td><td>'.render_guild_light($guild).'</td></tr></table>';

         if (User::is_user_authorize(User::USER_GROUP_ID)) {
            $content .= '<li class="menu"><a class="menu" href="guild.php?id='.$_SESSION['guild_id'].'">'.Language::get_instance()->get_label('lb_guild_info').'</a></li>'
                            .'<li class="menu"><a class="menu" href="log_book.php?id='.$_SESSION['guild_id'].'">'.Language::get_instance()->get_label('lb_log_book').'</a></li>'
                            .'<li class="menu"><a class="menu" href="member_list.php?id='.$_SESSION['guild_id'].'">'.Language::get_instance()->get_label('lb_member_list').'</a></li>'
                            .'<li class="menu"><a class="menu" href="guild_room.php?id='.$_SESSION['guild_id'].'">'.Language::get_instance()->get_label('lb_room_content').'</a></li>'
                            .'<li class="menu"><a class="menu" href="guild_room.php?id=-1">'.Language::get_instance()->get_label('lb_all_guild_room_content').'</a></li>'
                            .'<li class="menu"><a class="menu" href="transaction_book.php?id='.$_SESSION['guild_id'].'">'.Language::get_instance()->get_label('lb_room_transaction_book').'</a></li>'
                            .'<li class="menu"><a class="menu" href="javascript:;" onClick="dialog();">'.Language::get_instance()->get_label('lb_change_guild').'</a></li>'
                        .'</ul>'

                        .'<ul><b>'.Language::get_instance()->get_label('lb_search').'</b>'
                            .'<li class="menu"><a class="menu" href="item_search.php">'.Language::get_instance()->get_label('lb_item_search').'</a></li>'
                        .'</ul>';

         }
         else {
            $content .= '</ul>';
         }

         $content .= '<ul><b>'.Language::get_instance()->get_label('lb_user').'</b>'
                            .'<li class="menu"><a class="menu" href="update_data.php">'.Language::get_instance()->get_label('lb_add_api_key').'</a></li>'
                        .'</ul>';


         if (User::is_user_authorize(User::ADMIN_GROUP_ID)) {
             $content .= '<ul><b>'.Language::get_instance()->get_label('lb_administration').'</b>'
                            .'<li class="menu"><a class="menu" href="admin_panel.php">'.Language::get_instance()->get_label('lb_admin_panel').'</a></li>'
                            .'<li class="menu"><a class="menu" href="update_data.php?update=1">'.Language::get_instance()->get_label('lb_update_data').'</a></li>'
                        .'</ul>';
         }


         $content .= '</fieldset>';



        $content .= '<div id="dialog" title="'.Language::get_instance()->get_label('lb_guild_choice').'">';

        $guild_array = Guild::get_guild_list();

        $column_array = array();
        $column_array[] = Language::get_instance()->get_label('lb_guild');
        $column_array[] = '';

        $content .= generate_html_table_header($column_array, 263, true);

        foreach($guild_array as $guild) {
            $content .= '<tr><td valign="center">'.ryzom_guild_icon_image($guild->get_icon(), 's')
                    .'</td><td valign="center"><a class="menu" href="update_session.php?guild_id='.$guild->get_id().'" >'.$guild->get_name().'</a></td></tr>';
        }

        $content .= generate_html_table_footer();
        $content .= '</div>';
    }
    else {
       $content .= '<br/><br/><dd><b>'.Language::get_instance()->get_label('lb_no_guild_registered').'</br><a class="black" href="update_data.php" >'
                    .Language::get_instance()->get_label('lb_add_api_key').'</a></b></dd></fieldset>';
    }


    return $content;
}




?>
